#ifndef hash_h
#define hash_h

typedef int (*hdigest_t)(void *key);
typedef void * (*hindex_t)(int key_index);
typedef int (*hcmp_t)(void *key0, void *key1);

struct hash_entry{
  struct hash_entry *next;
  int index;
};

struct hash {
  int bucket_num;
  hdigest_t digest;
  hcmp_t cmp;
  hindex_t index;
  struct hash_entry *pool;
  struct hash_entry *buckets[0];
};

struct hash *hash_create(int cap, hdigest_t digest, hcmp_t cmp, hindex_t index);
void hash_destroy(struct hash *hash);
int hash_put(struct hash *hash, int index);
int hash_get(struct hash *hash, void *key);

#endif
